﻿// Decompiled with JetBrains decompiler
// Type: Netick.Tick
// Assembly: Netick, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 6726ECA1-C773-4CF7-8952-E81B30D93B52
// Assembly location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Runtime\Netick.dll
// XML documentation location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Runtime\Netick.xml

using System;

#nullable disable
namespace Netick;

/// <summary>Represents a network tick.</summary>
[Serializable]
public struct Tick : IEquatable<Tick>
{
  public int Value;

  public bool IsValid => this.Value != -1;

  [Obsolete("This will be removed in the future, use Value instead.")]
  public int TickValue
  {
    get => this.Value;
    set => this.Value = value;
  }

  public static Tick InvalidTick => new Tick(-1);

  public Tick(int rawValue)
    : this()
  {
    this.Value = rawValue;
  }

  public static Tick operator +(Tick a, int b) => new Tick(a.Value + b);

  public static Tick operator -(Tick a, int b) => new Tick(a.Value - b);

  public static int operator %(Tick a, int b) => a.Value % b;

  public static int operator -(Tick a, Tick b) => a.Value - b.Value;

  public static Tick operator ++(Tick a) => new Tick(a.Value + 1);

  public static bool operator >(Tick a, Tick b) => a - b > 0;

  public static bool operator <(Tick a, Tick b) => a - b < 0;

  public static bool operator >=(Tick a, Tick b) => a - b >= 0;

  public static bool operator <=(Tick a, Tick b) => a - b <= 0;

  public static bool operator ==(Tick a, Tick b) => a.Value == b.Value && a.IsValid == b.IsValid;

  public static bool operator !=(Tick a, Tick b) => a.Value != b.Value || a.IsValid != b.IsValid;

  public static implicit operator Tick(int val) => new Tick(val);

  public static implicit operator int(Tick val) => val.Value;

  public override int GetHashCode() => this.Value;

  public override bool Equals(object obj) => obj is Tick tick && tick.Value == this.Value;

  public bool Equals(Tick other) => this.Value == other.Value;

  public override string ToString() => this.Value.ToString();
}
